#!/bin/sh
# Compiling Dialing Russian Shallow Syntax
# the script is written by Alexey Sokirko 2003, sokirko@yandex.ru

halt() {
	echo  "======================"
	echo  "Error: $errorstr"
	echo
	exit  1
}


if [ -z $RML ]; then
	errorstr="you should first register variable \$RML"
	halt;
fi;

if [ -x /usr/bin/gmake ]; then
	make_tool=gmake
else
    make_tool=make
fi


echo "================ Compiling TestSynan ==================="
$make_tool -C $RML/Source/TestSynan mode=release

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile TestSynan"
	halt;
fi


echo "================ Compiling ConvertTrigramBinary   ==================="
$make_tool -C $RML/Source/ConvertTrigramBinary mode=release

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile ConvertTrigramBinary"
	halt;
fi


echo "================ Compiling SimpleGrammarPrecompiled ==================="
$make_tool -C $RML/Source/SimpleGrammarPrecompiled mode=release

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile SimpleGrammarPrecompiled"
	halt;
fi


echo "================ Compiling SynanDaemon ==================="
$make_tool -C $RML/Source/SynanDaemon mode=release_thread

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile SynanDaemon "
	halt;
fi


echo "================ Compiling CGI Script 'SynanCGI ' ==================="
$make_tool -C $RML/Source/SynanCGI  mode=release_thread

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile SynanCGI"
	halt;
fi

echo "================ Compiling MorphGen ==================="
$make_tool -C $RML/Source/MorphGen mode=release

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile MorphGen"
	halt;
fi

echo "================ Compiling TestLem ==================="
$make_tool -C $RML/Source/TestLem mode=release

if [ "$?" -ne "0" ]; then
	errorstr="cannot compile TestLem"
	halt;
fi


echo "Everything is OK. Try generate_morph_bin.sh  and generate_syn_bin.sh to generate dictionaries!"
